package com.huawei.hms.framework.network.grs.c.a;

import com.huawei.hms.framework.common.Logger;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.net.ssl.X509TrustManager;

public class b implements X509TrustManager {
    private static int ˊ = 0;
    private static int ˋ = 75;
    private static final byte[] ˎ = new byte[]{(byte) 67, (byte) -42, (byte) 122, (byte) -34, (byte) -6, (byte) 24, (byte) -18, (byte) -48, (byte) 72, (byte) -11, (byte) 1, (byte) 21, (byte) 0, (byte) -6, (byte) 14, (byte) 8, (byte) -72, (byte) 32, (byte) 29, (byte) 23, (byte) -35, (byte) 36, (byte) -2, (byte) 6, (byte) -10, (byte) 1, (byte) 18, (byte) -40, (byte) 40, (byte) 8, (byte) 4, (byte) -16, (byte) 16, (byte) -8, (byte) 5, (byte) -6, (byte) 24, (byte) -18, (byte) -48, (byte) 72, (byte) -11, (byte) 1, (byte) 21, (byte) 0, (byte) -6, (byte) 14, (byte) 8, (byte) -72, (byte) 56, (byte) 5, (byte) 16, (byte) 5, (byte) -67, (byte) 24, (byte) 37, (byte) 16, (byte) 5, (byte) -8, (byte) 0, (byte) 6, (byte) -3, (byte) 1, (byte) 22, (byte) -12, (byte) -29, (byte) 54, (byte) -18, (byte) 5, (byte) 14, (byte) 7, (byte) -8, (byte) 9, (byte) 2};
    private static int ॱ = 1;
    protected List<X509TrustManager> a = new ArrayList();

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public b(android.content.Context r12, java.lang.String r13) {
        /*
        r11 = this;
        r2 = 0;
        r3 = 1;
        r4 = 0;
        r11.<init>();
        r0 = new java.util.ArrayList;
        r0.<init>();
        r11.a = r0;
        if (r12 == 0) goto L_0x0011;
    L_0x000f:
        if (r13 != 0) goto L_0x0019;
    L_0x0011:
        r0 = new java.lang.IllegalArgumentException;
        r1 = "context or trust file is null";
        r0.<init>(r1);
        throw r0;
    L_0x0019:
        r0 = "X509";
        r5 = javax.net.ssl.TrustManagerFactory.getInstance(r0);	 Catch:{ all -> 0x016f }
        r0 = "bks";
        r1 = ˊ;	 Catch:{ Exception -> 0x01b2 }
        r1 = r1 + 59;
        r6 = r1 % 128;
        ॱ = r6;	 Catch:{ Exception -> 0x01b2 }
        r1 = r1 % 2;
        if (r1 != 0) goto L_0x002d;
    L_0x002d:
        r1 = 1;
        r1 = new java.lang.Object[r1];	 Catch:{ all -> 0x01a1 }
        r6 = 0;
        r1[r6] = r0;	 Catch:{ all -> 0x01a1 }
        r0 = ˎ;	 Catch:{ all -> 0x01a1 }
        r6 = 9;
        r0 = r0[r6];	 Catch:{ all -> 0x01a1 }
        r0 = -r0;
        r0 = (byte) r0;	 Catch:{ all -> 0x01a1 }
        r6 = ˎ;	 Catch:{ all -> 0x01a1 }
        r7 = 10;
        r6 = r6[r7];	 Catch:{ all -> 0x01a1 }
        r6 = -r6;
        r6 = (byte) r6;	 Catch:{ all -> 0x01a1 }
        r7 = ˎ;	 Catch:{ all -> 0x01a1 }
        r8 = 10;
        r7 = r7[r8];	 Catch:{ all -> 0x01a1 }
        r7 = (byte) r7;	 Catch:{ all -> 0x01a1 }
        r0 = ˏ(r0, r6, r7);	 Catch:{ all -> 0x01a1 }
        r0 = java.lang.Class.forName(r0);	 Catch:{ all -> 0x01a1 }
        r6 = ˎ;	 Catch:{ all -> 0x01a1 }
        r7 = 12;
        r6 = r6[r7];	 Catch:{ all -> 0x01a1 }
        r6 = (byte) r6;	 Catch:{ all -> 0x01a1 }
        r7 = r6 | 20;
        r7 = (byte) r7;	 Catch:{ all -> 0x01a1 }
        r8 = ˎ;	 Catch:{ all -> 0x01a1 }
        r9 = 12;
        r8 = r8[r9];	 Catch:{ all -> 0x01a1 }
        r8 = (byte) r8;	 Catch:{ all -> 0x01a1 }
        r6 = ˏ(r6, r7, r8);	 Catch:{ all -> 0x01a1 }
        r7 = 1;
        r7 = new java.lang.Class[r7];	 Catch:{ all -> 0x01a1 }
        r8 = 0;
        r9 = java.lang.String.class;
        r7[r8] = r9;	 Catch:{ all -> 0x01a1 }
        r0 = r0.getMethod(r6, r7);	 Catch:{ all -> 0x01a1 }
        r6 = 0;
        r0 = r0.invoke(r6, r1);	 Catch:{ all -> 0x01a1 }
        r0 = (java.security.KeyStore) r0;	 Catch:{ all -> 0x01a1 }
        r1 = r12.getAssets();	 Catch:{ all -> 0x016f }
        r6 = 2;
        r6 = new java.lang.Object[r6];	 Catch:{ all -> 0x0167 }
        r7 = 1;
        r6[r7] = r13;	 Catch:{ all -> 0x0167 }
        r7 = 0;
        r6[r7] = r1;	 Catch:{ all -> 0x0167 }
        r1 = 5;
        r7 = 0;
        r8 = 15235; // 0x3b83 float:2.1349E-41 double:7.527E-320;
        r1 = o.avb.ˏ(r1, r7, r8);	 Catch:{ all -> 0x0167 }
        r1 = (java.lang.Class) r1;	 Catch:{ all -> 0x0167 }
        r7 = "ˏ";
        r8 = 2;
        r8 = new java.lang.Class[r8];	 Catch:{ all -> 0x0167 }
        r9 = 0;
        r10 = android.content.res.AssetManager.class;
        r8[r9] = r10;	 Catch:{ all -> 0x0167 }
        r9 = 1;
        r10 = java.lang.String.class;
        r8[r9] = r10;	 Catch:{ all -> 0x0167 }
        r1 = r1.getMethod(r7, r8);	 Catch:{ all -> 0x0167 }
        r7 = 0;
        r1 = r1.invoke(r7, r6);	 Catch:{ all -> 0x0167 }
        r1 = (java.io.InputStream) r1;	 Catch:{ all -> 0x0167 }
        r1.reset();	 Catch:{ all -> 0x0162 }
        r2 = "";
        r6 = java.lang.String.class;
        r7 = "toCharArray";
        r8 = 0;
        r6 = r6.getMethod(r7, r8);	 Catch:{ all -> 0x0173 }
        r7 = 0;
        r2 = r6.invoke(r2, r7);	 Catch:{ all -> 0x0173 }
        r6 = 2;
        r6 = new java.lang.Object[r6];	 Catch:{ all -> 0x01bc }
        r7 = 1;
        r6[r7] = r2;	 Catch:{ all -> 0x01bc }
        r2 = 0;
        r6[r2] = r1;	 Catch:{ all -> 0x01bc }
        r2 = ˎ;	 Catch:{ all -> 0x01bc }
        r7 = 9;
        r2 = r2[r7];	 Catch:{ all -> 0x01bc }
        r2 = -r2;
        r2 = (byte) r2;	 Catch:{ all -> 0x01bc }
        r7 = ˎ;	 Catch:{ all -> 0x01bc }
        r8 = 10;
        r7 = r7[r8];	 Catch:{ all -> 0x01bc }
        r7 = -r7;
        r7 = (byte) r7;	 Catch:{ all -> 0x01bc }
        r8 = ˎ;	 Catch:{ all -> 0x01bc }
        r9 = 10;
        r8 = r8[r9];	 Catch:{ all -> 0x01bc }
        r8 = (byte) r8;	 Catch:{ all -> 0x01bc }
        r2 = ˏ(r2, r7, r8);	 Catch:{ all -> 0x01bc }
        r2 = java.lang.Class.forName(r2);	 Catch:{ all -> 0x01bc }
        r7 = "load";
        r8 = 2;
        r8 = new java.lang.Class[r8];	 Catch:{ all -> 0x01bc }
        r9 = 0;
        r10 = java.io.InputStream.class;
        r8[r9] = r10;	 Catch:{ all -> 0x01bc }
        r9 = 1;
        r10 = char[].class;
        r8[r9] = r10;	 Catch:{ all -> 0x01bc }
        r2 = r2.getMethod(r7, r8);	 Catch:{ all -> 0x01bc }
        r2.invoke(r0, r6);	 Catch:{ all -> 0x01bc }
        r5.init(r0);	 Catch:{ all -> 0x0162 }
        r5 = r5.getTrustManagers();	 Catch:{ all -> 0x0162 }
        r2 = r4;
    L_0x0104:
        r0 = r5.length;	 Catch:{ all -> 0x0162 }
        if (r2 >= r0) goto L_0x01a9;
    L_0x0107:
        r0 = r3;
    L_0x0108:
        switch(r0) {
            case 1: goto L_0x017b;
            default: goto L_0x010b;
        };	 Catch:{ all -> 0x0162 }
    L_0x010b:
        r0 = r11.a;	 Catch:{ all -> 0x0162 }
        r0 = r0.isEmpty();	 Catch:{ all -> 0x0162 }
        if (r0 == 0) goto L_0x01b4;
    L_0x0113:
        r0 = 28;
    L_0x0115:
        switch(r0) {
            case 93: goto L_0x01b8;
            default: goto L_0x0118;
        };	 Catch:{ all -> 0x0162 }
    L_0x0118:
        r0 = "X509TrustManager is empty";
        r2 = ॱ;
        r2 = r2 + 7;
        r3 = r2 % 128;
        ˊ = r3;
        r2 = r2 % 2;
        if (r2 == 0) goto L_0x0126;
    L_0x0126:
        r2 = 1;
        r2 = new java.lang.Object[r2];	 Catch:{ all -> 0x015a }
        r3 = 0;
        r2[r3] = r0;	 Catch:{ all -> 0x015a }
        r0 = ˎ;	 Catch:{ all -> 0x015a }
        r3 = 18;
        r0 = r0[r3];	 Catch:{ all -> 0x015a }
        r0 = r0 + -1;
        r0 = (byte) r0;	 Catch:{ all -> 0x015a }
        r3 = r0 + 2;
        r3 = (byte) r3;	 Catch:{ all -> 0x015a }
        r4 = ˎ;	 Catch:{ all -> 0x015a }
        r5 = 10;
        r4 = r4[r5];	 Catch:{ all -> 0x015a }
        r4 = (byte) r4;	 Catch:{ all -> 0x015a }
        r0 = ˏ(r0, r3, r4);	 Catch:{ all -> 0x015a }
        r0 = java.lang.Class.forName(r0);	 Catch:{ all -> 0x015a }
        r3 = 1;
        r3 = new java.lang.Class[r3];	 Catch:{ all -> 0x015a }
        r4 = 0;
        r5 = java.lang.String.class;
        r3[r4] = r5;	 Catch:{ all -> 0x015a }
        r0 = r0.getDeclaredConstructor(r3);	 Catch:{ all -> 0x015a }
        r0 = r0.newInstance(r2);	 Catch:{ all -> 0x015a }
        r0 = (java.lang.Throwable) r0;	 Catch:{ all -> 0x015a }
        throw r0;	 Catch:{ all -> 0x015a }
    L_0x015a:
        r0 = move-exception;
        r2 = r0.getCause();	 Catch:{ all -> 0x0162 }
        if (r2 == 0) goto L_0x019f;
    L_0x0161:
        throw r2;	 Catch:{ all -> 0x0162 }
    L_0x0162:
        r0 = move-exception;
    L_0x0163:
        com.huawei.hms.framework.common.IoUtils.closeSecure(r1);
        throw r0;
    L_0x0167:
        r0 = move-exception;
        r1 = r0.getCause();	 Catch:{ all -> 0x016f }
        if (r1 == 0) goto L_0x0172;
    L_0x016e:
        throw r1;	 Catch:{ all -> 0x016f }
    L_0x016f:
        r0 = move-exception;
        r1 = r2;
        goto L_0x0163;
    L_0x0172:
        throw r0;	 Catch:{ all -> 0x016f }
    L_0x0173:
        r0 = move-exception;
        r2 = r0.getCause();	 Catch:{ all -> 0x0162 }
        if (r2 == 0) goto L_0x01a0;
    L_0x017a:
        throw r2;	 Catch:{ all -> 0x0162 }
    L_0x017b:
        r0 = ॱ;	 Catch:{ Exception -> 0x01ad }
        r0 = r0 + 41;
        r6 = r0 % 128;
        ˊ = r6;	 Catch:{ Exception -> 0x01ad }
        r0 = r0 % 2;
        if (r0 == 0) goto L_0x0187;
    L_0x0187:
        r0 = r5[r2];	 Catch:{ all -> 0x0162 }
        r0 = r0 instanceof javax.net.ssl.X509TrustManager;	 Catch:{ all -> 0x0162 }
        if (r0 == 0) goto L_0x01af;
    L_0x018d:
        r0 = 3;
    L_0x018e:
        switch(r0) {
            case 23: goto L_0x019a;
            default: goto L_0x0191;
        };	 Catch:{ all -> 0x0162 }
    L_0x0191:
        r6 = r11.a;	 Catch:{ all -> 0x0162 }
        r0 = r5[r2];	 Catch:{ all -> 0x0162 }
        r0 = (javax.net.ssl.X509TrustManager) r0;	 Catch:{ all -> 0x0162 }
        r6.add(r0);	 Catch:{ all -> 0x0162 }
    L_0x019a:
        r0 = r2 + 1;
        r2 = r0;
        goto L_0x0104;
    L_0x019f:
        throw r0;	 Catch:{ all -> 0x0162 }
    L_0x01a0:
        throw r0;	 Catch:{ all -> 0x0162 }
    L_0x01a1:
        r0 = move-exception;
        r1 = r0.getCause();	 Catch:{ all -> 0x016f }
        if (r1 == 0) goto L_0x01c4;
    L_0x01a8:
        throw r1;	 Catch:{ all -> 0x016f }
    L_0x01a9:
        r0 = r4;
        goto L_0x0108;
    L_0x01ac:
        throw r0;	 Catch:{ all -> 0x0162 }
    L_0x01ad:
        r0 = move-exception;
        throw r0;
    L_0x01af:
        r0 = 23;
        goto L_0x018e;
    L_0x01b2:
        r0 = move-exception;
        throw r0;
    L_0x01b4:
        r0 = 93;
        goto L_0x0115;
    L_0x01b8:
        com.huawei.hms.framework.common.IoUtils.closeSecure(r1);	 Catch:{ Exception -> 0x01b2 }
        return;
    L_0x01bc:
        r0 = move-exception;
        r2 = r0.getCause();	 Catch:{ all -> 0x0162 }
        if (r2 == 0) goto L_0x01ac;
    L_0x01c3:
        throw r2;	 Catch:{ all -> 0x0162 }
    L_0x01c4:
        throw r0;	 Catch:{ all -> 0x016f }
        */
        throw new UnsupportedOperationException("Method not decompiled: com.huawei.hms.framework.network.grs.c.a.b.<init>(android.content.Context, java.lang.String):void");
    }

    private static java.lang.String ˏ(byte r7, byte r8, int r9) {
        /* JADX: method processing error */
/*
Error: jadx.core.utils.exceptions.JadxOverflowException: Regions stack size limit reached
	at jadx.core.utils.ErrorsCounter.addError(ErrorsCounter.java:37)
	at jadx.core.utils.ErrorsCounter.methodError(ErrorsCounter.java:61)
	at jadx.core.dex.visitors.DepthTraversal.visit(DepthTraversal.java:33)
	at jadx.core.dex.visitors.DepthTraversal.visit(DepthTraversal.java:17)
	at jadx.core.ProcessClass.process(ProcessClass.java:37)
	at jadx.core.ProcessClass.processDependencies(ProcessClass.java:59)
	at jadx.core.ProcessClass.process(ProcessClass.java:42)
	at jadx.api.JadxDecompiler.processClass(JadxDecompiler.java:306)
	at jadx.api.JavaClass.decompile(JavaClass.java:62)
*/
        /*
        r4 = r8 + 4;
        r0 = r9 * 3;
        r0 = r0 + 103;
        r1 = r7 + 11;
        r6 = ˎ;
        r3 = -1;
        r2 = new byte[r1];
        r1 = r1 + -1;
        if (r6 != 0) goto L_0x002c;
    L_0x0011:
        r5 = r4;
        r4 = r3;
        r3 = r2;
        r2 = r0;
        r0 = r1;
    L_0x0016:
        r0 = r0 + r2;
        r2 = r0 + -3;
    L_0x0019:
        r4 = r4 + 1;
        r5 = r5 + 1;
        r0 = (byte) r2;
        r3[r4] = r0;
        if (r4 != r1) goto L_0x0029;
    L_0x0022:
        r0 = new java.lang.String;
        r1 = 0;
        r0.<init>(r3, r1);
        return r0;
    L_0x0029:
        r0 = r6[r5];
        goto L_0x0016;
    L_0x002c:
        r5 = r4;
        r4 = r3;
        r3 = r2;
        r2 = r0;
        goto L_0x0019;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.huawei.hms.framework.network.grs.c.a.b.ˏ(byte, byte, int):java.lang.String");
    }

    public void checkClientTrusted(X509Certificate[] x509CertificateArr, String str) {
        if (this.a.isEmpty()) {
            throw new CertificateException("checkClientTrusted CertificateException");
        }
        ((X509TrustManager) this.a.get(0)).checkClientTrusted(x509CertificateArr, str);
    }

    public void checkServerTrusted(X509Certificate[] x509CertificateArr, String str) {
        if (this.a.isEmpty()) {
            throw new CertificateException("checkServerTrusted CertificateException");
        }
        X509TrustManager x509TrustManager = (X509TrustManager) this.a.get(0);
        Logger.v("SecureX509TrustManager", "checkServerTrusted authType{%s}", str);
        x509TrustManager.checkServerTrusted(x509CertificateArr, str);
    }

    public X509Certificate[] getAcceptedIssuers() {
        try {
            ArrayList arrayList = new ArrayList();
            for (X509TrustManager acceptedIssuers : this.a) {
                arrayList.addAll(Arrays.asList(acceptedIssuers.getAcceptedIssuers()));
            }
            return (X509Certificate[]) arrayList.toArray(new X509Certificate[arrayList.size()]);
        } catch (Exception e) {
            Logger.w("SecureX509TrustManager", "getAcceptedIssuers exception");
            return new X509Certificate[0];
        }
    }
}
